package com.larry.mr.order;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

/**
 * @ProjectName map-reduce
 * @Author larry
 * @Date 10:26 2022/4/7
 * @Description TODO
 **/
public class OrderGroupingComparator extends WritableComparator {

    public OrderGroupingComparator() {
        super(OrderBean.class,true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {

        OrderBean abean = (OrderBean) a;
        OrderBean bbean = (OrderBean) b;

        int res;

        if (abean.getOrder_id() > bbean.getOrder_id()){
            res = 1;
        }else if (abean.getOrder_id() < bbean.getOrder_id()){
            res = -1;
        }else {
            res = 0;
        }

        return res;
    }
}
